package gui.admin.tablemodel;

import dao.SupplierDao;
import entity.Supplier;

import javax.swing.table.DefaultTableModel;
import java.util.List;

public class SupplierTableModel extends DefaultTableModel {
    SupplierDao supplierDao = new SupplierDao();
    String[] tableHeaders = new String[]{"开发商编号","开发商名称","联系电话","地址"};//用户信息表头
    List supplierList = null;
    String[][] supplierData = null;
    public SupplierTableModel() throws Exception {
        supplierList = supplierDao.getAllSuppliers();
        supplierData = new String[supplierList.size()][tableHeaders.length];
        for (int i = 0; i < supplierList.size(); i++) {
            Supplier supplier = (Supplier)supplierList.get(i);
            supplierData[i][0] = supplier.getSupplierId();
            supplierData[i][1] = supplier.getSupplierName();
            supplierData[i][2] = supplier.getContactNumber();
            supplierData[i][3] = supplier.getAddress();
        }
        this.setDataVector(supplierData,tableHeaders);
    }
}
